//
//  XJShangPinEvaluateCell.m
//  XinJiangMall
//
//  Created by RaoBo on 2018/6/11.
//  Copyright © 2018年 Tzyang. All rights reserved.
//  高度固定为120

#import "XJShangPinEvaluateCell.h"
#import "XJShangPinEvaluateModel.h"

@interface XJShangPinEvaluateCell()
@property (weak, nonatomic) IBOutlet UIImageView *iconIv;
@property (weak, nonatomic) IBOutlet UILabel *nameLb;
@property (weak, nonatomic) IBOutlet UILabel *neirongLb;
@property (weak, nonatomic) IBOutlet UILabel *timeLb;

@end

@implementation XJShangPinEvaluateCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
    self.selectionStyle = UITableViewCellSelectionStyleNone;
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}


#pragma mark - 赋值 
- (void)setEvaluateM:(XJShangPinEvaluateModel *)evaluateM {
    
    UIImage *placeholderImg = [UIImage imageNamed:@"default_head"];
    
    [self.iconIv sd_setImageWithURL:[NSURL URLWithString:evaluateM.customer_avatar] placeholderImage:placeholderImg];
    self.nameLb.text = evaluateM.customer_name;
    self.neirongLb.text = evaluateM.content;
//    self.timeLb.text = @"Java";
    self.timeLb.text = [self timestampSwitchTime:[evaluateM.create_time doubleValue]];
}


#pragma mark - Private methods
/// 时间戳转时间字符串

- (NSString *)timestampSwitchTime:(double)timestamp{
    
    //fmt
    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
    [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"];
    
    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:(timestamp / 1000.0)];//java 生成的时间戳单位是毫秒
    
    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
    return confromTimespStr;
}


//- (NSString *)timestampSwitchTime:(double)timestamp{
//
//    NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
//
//    [formatter setDateStyle:NSDateFormatterMediumStyle];
//
//    [formatter setTimeStyle:NSDateFormatterShortStyle];
//
//    [formatter setDateFormat:@"YYYY-MM-dd hh:mm:ss"]; // （@"YYYY-MM-dd hh:mm:ss"）----------设置你想要的格式,hh与HH的区别:分别表示12小时制,24小时制
//
//    NSTimeZone *timeZone = [NSTimeZone timeZoneWithName:@"Asia/Beijing"];
//
//    [formatter setTimeZone:timeZone];
//
//    NSDate *confromTimesp = [NSDate dateWithTimeIntervalSince1970:(timestamp / 1000.0)];
//
//    //    NSLog(@"1296035591  = %@",confromTimesp);
//
//    NSString *confromTimespStr = [formatter stringFromDate:confromTimesp];
//
//    //NSLog(@"&&&&&&&confromTimespStr = : %@",confromTimespStr);
//
//    return confromTimespStr;
//}
@end
